package com.bobo.serviceorder.service.impl;

import com.bobo.serviceorder.dao.TblOrderDao;
import com.bobo.serviceorder.entry.TblOrder;
import com.bobo.serviceorder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author bobo
 * @date 2021-04-12
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private TblOrderDao tblOrderDao;

    @Override
    public boolean grabOrder(int orderId, int driverId) {

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        TblOrder tblOrder = tblOrderDao.selectByPrimaryKey(orderId);

        // 还有填写其他很多业务信息。包括哪个司机啥的。起点，终点。
        if (tblOrder.getOrderStatus() == 0) {
            tblOrder.setOrderStatus(1);
            tblOrderDao.updateByPrimaryKey(tblOrder);
            return true;
        }

        return false;
    }
}
